package gestionColis;

/**
 * Interface definition : GestStation
 * 
 * @author OpenORB Compiler
 */
public abstract class GestStationPOA extends org.omg.PortableServer.Servant
        implements GestStationOperations, org.omg.CORBA.portable.InvokeHandler
{
    public GestStation _this()
    {
        return GestStationHelper.narrow(_this_object());
    }

    public GestStation _this(org.omg.CORBA.ORB orb)
    {
        return GestStationHelper.narrow(_this_object(orb));
    }

    private static String [] _ids_list =
    {
        "IDL:gestionColis/GestStation:1.0"
    };

    public String[] _all_interfaces(org.omg.PortableServer.POA poa, byte [] objectId)
    {
        return _ids_list;
    }

    public final org.omg.CORBA.portable.OutputStream _invoke(final String opName,
            final org.omg.CORBA.portable.InputStream _is,
            final org.omg.CORBA.portable.ResponseHandler handler)
    {

        if (opName.equals("calculerCoutTransport")) {
                return _invoke_calculerCoutTransport(_is, handler);
        } else if (opName.equals("demandeReservationCasier")) {
                return _invoke_demandeReservationCasier(_is, handler);
        } else if (opName.equals("enregistrerStation")) {
                return _invoke_enregistrerStation(_is, handler);
        } else if (opName.equals("recupererStationAdhesion")) {
                return _invoke_recupererStationAdhesion(_is, handler);
        } else {
            throw new org.omg.CORBA.BAD_OPERATION(opName);
        }
    }

    // helper methods
    private org.omg.CORBA.portable.OutputStream _invoke_recupererStationAdhesion(
            final org.omg.CORBA.portable.InputStream _is,
            final org.omg.CORBA.portable.ResponseHandler handler) {
        org.omg.CORBA.portable.OutputStream _output;
        gestionColis.InfoAdherent arg0_in = gestionColis.InfoAdherentHelper.read(_is);

        try
        {
            gestionColis.InfoStation _arg_result = recupererStationAdhesion(arg0_in);

            _output = handler.createReply();
            gestionColis.InfoStationHelper.write(_output,_arg_result);

        }
        catch (gestionColis.AdresseNonDesservieException _exception)
        {
            _output = handler.createExceptionReply();
            gestionColis.AdresseNonDesservieExceptionHelper.write(_output,_exception);
        }
        return _output;
    }

    private org.omg.CORBA.portable.OutputStream _invoke_calculerCoutTransport(
            final org.omg.CORBA.portable.InputStream _is,
            final org.omg.CORBA.portable.ResponseHandler handler) {
        org.omg.CORBA.portable.OutputStream _output;
        gestionColis.InfoStation arg0_in = gestionColis.InfoStationHelper.read(_is);
        gestionColis.InfoStation arg1_in = gestionColis.InfoStationHelper.read(_is);

        try
        {
            double _arg_result = calculerCoutTransport(arg0_in, arg1_in);

            _output = handler.createReply();
            _output.write_double(_arg_result);

        }
        catch (gestionColis.StationInconnueException _exception)
        {
            _output = handler.createExceptionReply();
            gestionColis.StationInconnueExceptionHelper.write(_output,_exception);
        }
        return _output;
    }

    private org.omg.CORBA.portable.OutputStream _invoke_demandeReservationCasier(
            final org.omg.CORBA.portable.InputStream _is,
            final org.omg.CORBA.portable.ResponseHandler handler) {
        org.omg.CORBA.portable.OutputStream _output;
        gestionColis.InfoStation arg0_in = gestionColis.InfoStationHelper.read(_is);
        gestionColis.InfoColis arg1_in = gestionColis.InfoColisHelper.read(_is);

        try
        {
            demandeReservationCasier(arg0_in, arg1_in);

            _output = handler.createReply();

        }
        catch (gestionColis.StationInconnueException _exception)
        {
            _output = handler.createExceptionReply();
            gestionColis.StationInconnueExceptionHelper.write(_output,_exception);
        }
        catch (gestionColis.AucuneCasierDispoException _exception)
        {
            _output = handler.createExceptionReply();
            gestionColis.AucuneCasierDispoExceptionHelper.write(_output,_exception);
        }
        return _output;
    }

    private org.omg.CORBA.portable.OutputStream _invoke_enregistrerStation(
            final org.omg.CORBA.portable.InputStream _is,
            final org.omg.CORBA.portable.ResponseHandler handler) {
        org.omg.CORBA.portable.OutputStream _output;
        gestionColis.Station arg0_in = gestionColis.StationHelper.read(_is);
        String arg1_in = _is.read_string();

        try
        {
            enregistrerStation(arg0_in, arg1_in);

            _output = handler.createReply();

        }
        catch (gestionColis.StationNonConfigureeException _exception)
        {
            _output = handler.createExceptionReply();
            gestionColis.StationNonConfigureeExceptionHelper.write(_output,_exception);
        }
        return _output;
    }

}
